package com.ecfront.service.impl;

import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;

import com.ecfront.dao.AdminDAO;
import com.ecfront.exception.UserException;
import com.ecfront.pojo.Admin;
import com.ecfront.service.AdminService;

public class AdminServiceImpl implements AdminService {
	//日志文件
	private static Logger log = Logger.getLogger(UserServiceImpl.class.getName());

	private AdminDAO adminDAO;
	
	public AdminDAO getAdminDAO() {
		return adminDAO;
	}

	public void setAdminDAO(AdminDAO adminDAO) {
		this.adminDAO = adminDAO;
	}

	public void delete(Admin persistentInstance) {
		// TODO Auto-generated method stub
		
	}

	public List findAll() {
		// TODO Auto-generated method stub
		return null;
	}

	public Admin findByAdminId(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	public List findByAdminName(Object adminName) {
		// TODO Auto-generated method stub
		return null;
	}

	public List findByProperty(String propertyName, Object value) {
		// TODO Auto-generated method stub
		return null;
	}

	public void loginAdmin(Admin admin,Date lastLoginDate,Date lastLoginErrorDate,String lastLoginIP,String lastLoginErrorIP){
		try{
		Admin a=new Admin();
		a.setAdminId(admin.getAdminId());
		a.setAdminName(admin.getAdminName());
		a.setAdminPassword(admin.getAdminPassword());
		a.setLastLoginDate(lastLoginDate);
		a.setLastLoginErrorDate(lastLoginErrorDate);
		a.setLastLoginIP(lastLoginIP);
		a.setLastLoginErrorIP(lastLoginErrorIP);
		a.setPowerId(admin.getPowerId());
		adminDAO.save(a);
		}catch (Exception e) {
			log.debug(e.getMessage());
		}
	}
	

	public Admin findAdminByAdminNameAndAdminPassword(String adminName,
			String adminPassword) {
		return adminDAO.findAdminByAdminNameAndAdminPassword(adminName, adminPassword);
	}

	public void addOrUpdateAdmin(int adminId, String adminName,
			String adminPassword, Date lastLoginDate, Date lastLoginErrorDate,
			String lastLoginIP, String lastLoginErrorIP) {
		// TODO Auto-generated method stub
		
	}

	
}
